package com.agua.enturno.servicios.impl;

import com.agua.enturno.persistencia.dao.RubroDAO;
import com.agua.enturno.servicios.RubroService;
import com.agua.enturno.vista.dto.PrestadorDeServiciosDTO;
import com.agua.enturno.vista.dto.RubroDTO;
import com.agua.enturno.vista.dto.RubroFullDTO;
import com.agua.enturno.vista.dto.assemblers.PrestadorDeServiciosAssembler;
import com.agua.enturno.vista.dto.assemblers.RubroAssembler;
import com.agua.enturno.vista.dto.assemblers.RubroFullAssembler;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public class RubroServiceImpl implements RubroService {

	private RubroDAO rubroDAO;
	private RubroAssembler rubroAssembler;
	private RubroFullAssembler rubroFullAssembler;
	private PrestadorDeServiciosAssembler prestadorDeServiciosAssembler;
	
	
	/*------------------------------------ Public methods ----------------------------------*/

	@Override
	@Transactional
	public List<RubroDTO> findAll() {
		return rubroAssembler.assemble(rubroDAO.findAll());
	}
	
	@Override
	@Transactional
	public List<RubroFullDTO> findAllFull() {
		return rubroFullAssembler.assemble(rubroDAO.findAll());
	}
	
	@Override
	@Transactional
	public List<PrestadorDeServiciosDTO> findPrestadores(Long rubroId) {
		return prestadorDeServiciosAssembler.assemble(rubroDAO.findById(rubroId).getPrestadoresDeServicio());
	}

	/*--------------------------------------------------------------------------------------*/
	/*---------------------------------- Geters and seters ---------------------------------*/

	public void setRubroDAO(RubroDAO rubroDAO) {
		this.rubroDAO = rubroDAO;
	}

	public void setRubroAssembler(RubroAssembler rubroAssembler) {
		this.rubroAssembler = rubroAssembler;
	}

	public void setRubroFullAssembler(RubroFullAssembler rubroFullAssembler) {
		this.rubroFullAssembler = rubroFullAssembler;
	}

	public void setPrestadorDeServiciosAssembler(PrestadorDeServiciosAssembler prestadorDeServiciosAssembler) {
		this.prestadorDeServiciosAssembler = prestadorDeServiciosAssembler;
	}
	
	/*--------------------------------------------------------------------------------------*/

}
